home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Lib / table / tb_1148gate.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  1.3 KB  |  66 lines

  1. /* tb_1148gate: look up domain in table of 1148 gateways */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Lib/table/RCS/tb_1148gate.c,v 6.0 1991/12/18 20:24:28 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Lib/table/RCS/tb_1148gate.c,v 6.0 1991/12/18 20:24:28 jpo Rel $
  9.  *
  10.  * $Log: tb_1148gate.c,v $
  11.  * Revision 6.0  1991/12/18  20:24:28  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. #include "or.h"
  19. #include "util.h"
  20. #include "table.h"
  21.  
  22. static Table    *tb_1148gateways = NULLTBL;
  23. extern char    *rfc1148gateway_tbl, *loc_or, or_error[];
  24.  
  25. int tb_get1148gate (domain, or)
  26. char    *domain;
  27. OR_ptr    *or;
  28. {
  29.     char    *p, buf[LINESIZE];
  30.     
  31.     PP_DBG (("Lib/tb_get1148gate (%s)", domain));
  32.  
  33.     if (tb_1148gateways == NULLTBL) {
  34.         if ((tb_1148gateways = tb_nm2struct (rfc1148gateway_tbl)) == NULLTBL) {
  35.             PP_LOG (LLOG_EXCEPTIONS, ("Lib/tb_get1148gate: rfc1148gateway table NULL!"));
  36.             return NOTOK;
  37.         }
  38.     }
  39.     
  40.     for (p = domain; *p != '\0';) {
  41.         if (tb_k2val (tb_1148gateways, p, buf, TRUE) == OK)
  42.             break;
  43.         p = index (p, '.');
  44.         if (p == NULLCP)
  45.             break;
  46.         else
  47.             p++;
  48.     }
  49.  
  50.  
  51.     if (p == NULLCP || *p == '\0') {
  52.         (void) sprintf (or_error,
  53.                 "Unable to find rfc1148 gateway for '%s'",
  54.                 domain);
  55.         return NOTOK;
  56.     }
  57.     else {
  58.         *or = or_dmn2or (buf);
  59.         if (*or == NULLOR)
  60.             return or_lose ("format error '%s':'%s'",
  61.                     p, buf);
  62.     }
  63.  
  64.     return OK;
  65. }
  66.